﻿using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SharePointPOBox.TicketVendorWebPart
{
    /// <summary>WebPart to vend ticket for upload file</summary>
    [ToolboxItemAttribute(false)]
    public class TicketVendorWebPart : WebPart
    {
        #region events

        /// <summary>CreateChildControls</summary>
        protected override void CreateChildControls()
        {
            SPList defaultLib = Common.GetLibrary(Common.DefaultLibraryURL, false);
            if (defaultLib != null && defaultLib.DoesUserHavePermissions(SPBasePermissions.AddListItems))
            {
                this.Controls.Add(new Button()
                {
                    Text = Common.CurLngStr("SPPOBTicketVendorWebPart_ShowDialogButton"),
                    OnClientClick = "ShowPopupTicketVendorDialog('" + SPContext.Current.Site.Url.TrimEnd("/".ToCharArray()) + "/_layouts/SharePointPOBox/TicketVendor.aspx','" + Common.CurLngStr("SPPOBTicketVendorWebPart_DialogTitle") + "'); return false;"
                });
                this.Controls.Add(new ScriptLink()
                {
                    Name = "~sitecollection/_layouts/SharePointPOBox/SPPOBTicketVendor.js",
                    Language = "javascript"
                });
            }
        }

        #endregion events
    }
}
